#include "../global.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    vtkCreate(cylinder, vtkCylinderSource);
    cylinder->SetHeight( 3.0 );
    cylinder->SetRadius( 1.0 );
    cylinder->SetResolution( 10 );

    vtkCreate(cylinderMapper, vtkPolyDataMapper);
    cylinderMapper->SetInputConnection( cylinder->GetOutputPort() );

    vtkCreate(cylinderActor, vtkActor);
    vtkCreate(bmpReader, vtkBMPReader);
    bmpReader->SetFileName("F:\\Picture\\CF\\d6a31837f66cb9d6a8018e5e.bmp");

    vtkCreate(texture, vtkTexture);
    texture->SetInputConnection(bmpReader->GetOutputPort());
    texture->InterpolateOn();

    cylinderActor->SetTexture( texture );
    cylinderActor->SetMapper( cylinderMapper );

    vtkCreate(renderer, vtkRenderer);
    renderer->AddActor( cylinderActor );
    renderer->SetBackground( 0.1, 0.2, 0.4 );

    vtkCreate(light1, vtkLight);
    light1->SetColor(0,1,0);
    light1->SetPosition(0,0,1);
    light1->SetFocalPoint(renderer->GetActiveCamera()->GetFocalPoint());
    renderer->AddLight(light1);

    vtkCreate(light2, vtkLight);
    light2->SetColor(0,0,1);
    light2->SetPosition(0,0,-1);
    light2->SetFocalPoint(renderer->GetActiveCamera()->GetFocalPoint());
    renderer->AddLight(light2);

    vtkCamera *camera = renderer->GetActiveCamera();
    camera->SetViewUp(0,0,-1);
    camera->SetPosition(0,1,0);
    camera->SetFocalPoint(0,0,0);
    camera->Dolly(1.5);
    renderer->SetActiveCamera(camera);
    renderer->ResetCameraClippingRange();

    vtkCreate(style, vtkInteractorStyleTrackballCamera);
    vtkWidgetCreate(widget, QVTKWidget);
    QVTKWidget* vtkWidget = widget.data();
    vtkWidget->GetRenderWindow()->AddRenderer(renderer);
    vtkWidget->GetRenderWindow()->GetInteractor()->SetInteractorStyle(style);
    vtkWidget->resize(WINDOW_WIDTH, WINDOW_HEIGHT);
    vtkWidget->show();

    return a.exec();
}
